home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1999 #2
/
Amiga Plus CD - 1999 - No. 2.iso
/
System-Boost
/
Workbench
/
Archive
/
PP_v1.4
/
Source
/
ports.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-11-08
|
1KB
|
64 lines
/* Ports.C - Port creating/freeing functions
**
** Herein you will find CreatePort() and DeletePort(). It is quite possible
** that your stdlib already contains these, but just to make sure (and for
** the sake of example), here they are!
**
** This file belongs to the Powerpacker Patcher project
**
** Copyright 1991, Michael Berg
*/
#include <pragmas.h>
#include <exec/types.h>
#include <exec/ports.h>
#include <exec/nodes.h>
#include <exec/memory.h>
/* CreatePort() should exist in the standard library, but here it is, just
** in case your library lacks this function (it isn't in ROM)
*/
struct MsgPort *myCreatePort(register char *name, register pri)
{
register UBYTE sigbit;
register struct MsgPort *gotten;
if
(
gotten = (struct MsgPort *)AllocMem
(
sizeof(*gotten),
MEMF_CLEAR | MEMF_PUBLIC
)
)
{
if ((sigbit = AllocSignal(-1)) != -1)
{
gotten->mp_Node.ln_Name = name;
gotten->mp_Node.ln_Pri = pri;
gotten->mp_Node.ln_Type = NT_MSGPORT;
gotten->mp_Flags = PA_SIGNAL;
gotten->mp_SigBit = sigbit;
gotten->mp_SigTask = FindTask(0);
AddPort(gotten);
return(gotten);
}
else
FreeMem((char *)gotten,sizeof(*gotten));
}
return(NULL);
}
/* DeletePort is also supposed to be in your standard library. Here it is,
** just in case...
*/
void myDeletePort(register struct MsgPort *p)
{
RemPort(p);
FreeSignal(p->mp_SigBit);
FreeMem((char *)p,sizeof(*p));
}